CC := g++
LD := g++
DCFLAGS := -O0 -g -W -Wall -Werror -std=c++0x `pkg-config gtkmm-2.4  --cflags` `pkg-config gtkglextmm-1.2 --cflags`
RCFLAGS := -O3 -W -Wall -Werror -std=c++0x `pkg-config gtkmm-2.4  --cflags` `pkg-config gtkglextmm-1.2 --cflags`
CFLAGS := $(DCFLAGS)
LFLAGS := -lboost_system -lGLEW -lGLU -lGL -lboost_iostreams `pkg-config gtkmm-2.4  --libs` `pkg-config gtkglextmm-1.2 --libs`

SRCDIR   := .
OBJDIR   := .
PROJDIRS := .

SRCFILES    := $(shell find $(PROJDIRS) -type f -name "*.cpp")
HDRFILES    := $(shell find $(PROJDIRS) -type f -name "*.h")
OBJFILES    := $(patsubst %.cpp,%.o,$(SRCFILES))
DEPFILES    := $(patsubst %.cpp,%.d,$(SRCFILES))

moogle: $(OBJFILES)
	$(LD) $(LFLAGS) -o $@ $(OBJFILES)

NODEPS:=clean
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
  -include $(DEPFILES)
endif

%.o: %.cpp %.d %.h Makefile
	$(CC) $(CFLAGS) -c $< -o $@

%.d: %.cpp
	$(CC) $(CFLAGS) -MM -MT '$(patsubst %.cpp,%.o,$<)' $< > $@

debug: moogle
	gdb $^

run : moogle
	./$^

clean:
	rm -f *.o
	rm -f *.d
	rm -f moogle
